package edu.object_oriented.API;

import java.text.DecimalFormat;
import java.util.Scanner;

public class FormatNumber {

    public static void main(String[] args) {
        // 实例化DecimalFormat类的对象，并指定格式
        DecimalFormat df1 = new DecimalFormat("0.0");
        DecimalFormat df2 = new DecimalFormat("#.#");
        DecimalFormat df3 = new DecimalFormat("000.000");
        DecimalFormat df4 = new DecimalFormat("###.###");
        Scanner scan = new Scanner(System.in);
        System.out.print("请输入一个float类型的数字：");
        float f = scan.nextFloat();
        System.out.println("df1.format(f) = " + df1.format(f));
        System.out.println("df2.format(f) = " + df2.format(f));
    }

}
